home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
mflzt.exe
/
lha
/
MFLTIME.H
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-02
|
9KB
|
211 lines
/************************************************************************/
/* */
/* MFLTIME Header file */
/* */
/* Function prototypes for time-related functions. */
/* */
/* Copyright 1989 by Robert B. Stout dba MicroFirm */
/* All rights reserved */
/* */
/* Copyright 1986, 1987 by S.E. Margison */
/* */
/* Compiled by and for use with Zortech C/C++ 1.07 or later. */
/* */
/************************************************************************/
#ifndef MFLTIME_H
#define MFLTIME_H
#include <stdio.h>
#include <time.h>
#include <mfldefs.h>
#ifndef _Cdecl_
#if __ZTC__ > 0x107
#define CONST__ const
#ifdef __STDC__
#define _Cdecl_
#else
#define _Cdecl_ cdecl
#endif
#else
#define CONST__
#define _Cdecl_
#endif
#endif
#if __ZTC__ > 0x107
#if __cplusplus
extern "C" {
#endif
#endif
/************************************************************************/
/* */
/* Microsecond accuracy timing operations. */
/* */
/************************************************************************/
typedef unsigned long uclock_t;
#define UCLK_TCK 1000000L /* Usec per second - replaces CLK_TCK */
#define usec_difftime(start,finish) (finish-start)
uclock_t _Cdecl_ usec_clock(void);
void _Cdecl_ restart_uclock(void);
uclock_t _Cdecl_ usec_delay(uclock_t);
LOGICAL _Cdecl_ usec_timeout(uclock_t, uclock_t, uclock_t);
void _Cdecl_ msec_pause(long);
/************************************************************************/
/* */
/* ANSI functions */
/* */
/************************************************************************/
#if __ZTC__ > 0x107
size_t _Cdecl_ strftime(char *, size_t, const char *, const struct tm *);
#else
size_t _Cdecl_ strftime(char *, size_t, char *, struct tm *);
#endif
/************************************************************************/
/* */
/* Time zone functions */
/* */
/************************************************************************/
extern int daylight;
extern long timezone;
int tzset(void);
/************************************************************************/
/* */
/* Julian (scalar) date functions */
/* */
/************************************************************************/
long _Cdecl_ ymd_to_julian (unsigned, unsigned, unsigned);
void _Cdecl_ julian_to_ymd (long, unsigned *, unsigned *, unsigned *);
int _Cdecl_ julian_to_wkday(long);
char * _Cdecl_ julian_to_dayname(long);
unsigned _Cdecl_ julian_to_yrday(long);
LOGICAL _Cdecl_ julian_to_time(long, time_t *);
LOGICAL _Cdecl_ julian_to_tm(long, struct tm *);
long _Cdecl_ time_to_julian(time_t);
long _Cdecl_ tm_to_julian(struct tm *);
/************************************************************************/
/* */
/* Structures & functions for accessing file dates and times */
/* */
/************************************************************************/
#ifndef FTIME_DEF__
#define FTIME_DEF__
struct ftime {
unsigned int ft_tsec : 5;
unsigned int ft_min : 6;
unsigned int ft_hour : 5;
unsigned int ft_day : 5;
unsigned int ft_month : 4;
unsigned int ft_year : 7;
} ;
int _Cdecl_ getftime(int, struct ftime *);
int _Cdecl_ setftime(int, struct ftime *);
int _Cdecl_ touch(char *);
void _Cdecl_ get_filetime(struct tm *, int);
#endif /* FTIME_DEF__ */
/************************************************************************/
/* */
/* Misc functions */
/* */
/************************************************************************/
void _Cdecl_ installtick(int *),
_Cdecl_ removetick(void),
_Cdecl_ gtodsub(FILE *),
_Cdecl_ gtodstr(char *);
int _Cdecl_ daynum(int, int, int),
_Cdecl_ isleap(unsigned),
_Cdecl_ weekday(int, int, int);
char * _Cdecl_ monthis(int),
* _Cdecl_ wkdayname(int);
/************************************************************************/
/* */
/* Alternative file date and time functions */
/* */
/************************************************************************/
struct DOS_TIME
{
unsigned int ss : 5;
unsigned int mm : 6;
unsigned int hh : 5;
} ;
struct DOS_DATE
{
unsigned int da : 5;
unsigned int mo : 4;
unsigned int yr : 7;
} ;
#if __ZTC__ > 0x107
#if __cplusplus
}
#endif
#endif
#define dos_time(t) (*(struct DOS_TIME *)(&(t)))
#define dos_date(t) (*(struct DOS_DATE *)(&(t)))
/*
** Demo code for using above structures
*/
#if 0
*************************************************************************
* *
* /* Sample file date and time display.*/ *
* *
* #include <stdio.h> *
* #include <dos.h> *
* *
* main(int argc, char *argv[]) *
* { *
* struct FIND *ffblk; *
* *
* if (2 > argc) *
* { *
* puts("\aUsage: SHOWDATE filename[.ext]"); *
* exit(1); *
* } *
* if (!(ffblk = findfirst(argv[1], 0xff))) *
* { *
* printf("\aCant find %s\n", argv[1]); *
* exit(2); *
* } *
* printf("File date is %d-%d-%d\n", *
* dos_date(ffblk->date).mo,